import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '编号',
    align:"center",
    sorter: true,
    dataIndex: 'code'
   },
   {
    title: '名称',
    align:"center",
    sorter: true,
    dataIndex: 'name',
    width: 200
   },
   {
    title: '简称',
    align:"center",
    sorter: true,
    dataIndex: 'shortName'
   },
  //  {
  //   title: '部门ID',
  //   align:"center",
  //   dataIndex: 'departId'
  //  },
   {
    title: '部门',
    align:"center",
    sorter: true,
    dataIndex: 'departName',
    width: 200
   },
  //  {
  //   title: '交易币种ID',
  //   align:"center",
  //   dataIndex: 'currencyId'
  //  },
   {
    title: '交易币种',
    align:"center",
    dataIndex: 'currencyName',
   },
   {
    title: '启用门户',
    align:"center",
    dataIndex: 'enablePortal',
    customRender: ({ text }) => {
      return text === 1 ? '启用' : '未启用'
    },
   },
  //  {
  //   title: '业务员ID',
  //   align:"center",
  //   dataIndex: 'salesmanId'
  //  },
   {
    title: '业务员',
    align:"center",
    dataIndex: 'salesmanName'
   },
  //  {
  //   title: '价目表ID',
  //   align:"center",
  //   dataIndex: 'tariffId'
  //  },
   {
    title: '价目表',
    align:"center",
    dataIndex: 'tariffName'
   },
   {
    title: '关联账号',
    align:"center",
    dataIndex: 'associatedAccount'
   },
   {
    title: '联系电话',
    align:"center",
    dataIndex: 'mobile'
   },
  //  {
  //   title: '付款条件ID',
  //   align:"center",
  //   dataIndex: 'paymentConditionId'
  //  },
   {
    title: '付款条件',
    align:"center",
    dataIndex: 'paymentConditionName'
   },
   {
    title: '质保方式',
    align:"center",
    dataIndex: 'qualityAssuranceMethod_dictText'
   },
   {
    title: '企业邮箱',
    align:"center",
    dataIndex: 'email'
   },
  //  {
  //   title: '立账条件ID',
  //   align:"center",
  //   dataIndex: 'accountConditionId'
  //  },
   {
    title: '立账条件',
    align:"center",
    dataIndex: 'accountConditionName'
   },
   {
    title: '分类',
    align:"center",
    dataIndex: 'supplierClass'
   },
   {
    title: '发票核销顺序',
    align:"center",
    dataIndex: 'invoiceWriteOffOrder_dictText'
   },
   {
    title: '行业',
    align:"center",
    dataIndex: 'trade'
   },
   {
    title: '核销明细',
    align:"center",
    dataIndex: 'writeOffDetail_dictText'
   },
   {
    title: '收货原则ID',
    align:"center",
    dataIndex: 'receivingPrincipleId'
   },
   {
    title: '收货原则',
    align:"center",
    dataIndex: 'receivingPrincipleName'
   },
   {
    title: '单据核销顺序',
    align:"center",
    dataIndex: 'billWriteOffOrder_dictText'
   },
   {
    title: '办公地址',
    align:"center",
    dataIndex: 'officeAddress',
    width: 230
   },
   {
    title: '启用状态',
    align:"center",
    dataIndex: 'enableStatus',
    width: 100,
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'1'},{text:'否',value:'0'}])
     },
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
   {
    title: '第三方编码',
    align:"center",
    dataIndex: 'thirdPartyCode'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "编号",
      field: 'code',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "名称",
      field: 'name',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "部门",
      field: 'departName',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "业务员",
      field: 'salesmanName',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "价目表",
      field: 'tariffName',
      component: 'Input',
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'code',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入编号!'},
          ];
     },
  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入名称!'},
          ];
     },
  },
  {
    label: '简称',
    field: 'shortName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入简称!'},
          ];
     },
  },
  {
    label: '部门ID',
    field: 'departId',
    component: 'Input',
    show:false
  },
  {
    label: '部门',
    field: 'departId',
    component: 'JSelectDept',
    componentProps: ({}) => {
      return {
        multiple: false,
        showButton: false,
        checkable: false,
        labelKey: 'departName'

      }
    },
  },
  {
    label: '交易币种ID',
    field: 'currencyId',
    component: 'Input',
    show:false
  },
  {
    label: '交易币种',
    field: 'currencyName',
    component: 'Input',
    slot: 'currencySlot',
  },
  {
    label: '启用门户',
    field: 'enablePortal',
    component: 'JSwitch',
    componentProps: {
      options: ['1', '0'],
    },
  },
  // {
  //   label: '业务员ID',
  //   field: 'salesmanId',
  //   component: 'Input',
  //   show:false
  // },
  {
    label: '业务员',
    field: 'salesmanId',
    component: 'JSelectUserByDept',
    componentProps: {
      isRadioSelection:true,
      rowKey: 'id',
      labelKey: 'realname',
      showButton: false
    },
  },
  {
    label: '价目表ID',
    field: 'tariffId',
    component: 'Input',
    show:false
  },
  {
    label: '价目表',
    field: 'tariffName',
    component: 'Input',
  },
  {
    label: '关联账号',
    field: 'associatedAccount',
    component: 'Input',
  },
  {
    label: '联系电话',
    field: 'mobile',
    component: 'Input',
    rules: rules.rule('phone', false),
  },
  {
    label: '付款条件ID',
    field: 'paymentConditionId',
    component: 'Input',
    show:false
  },
  {
    label: '付款条件',
    field: 'paymentConditionName',
    component: 'Input',
    slot:'paymentConditionSlot'
  },
  {
    label: '质保方式',
    field: 'qualityAssuranceMethod',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"supplier_quality_assurance_method",
        stringToNumber: true,
     },
  },
  {
    label: '企业邮箱',
    field: 'email',
    component: 'Input',
  },
  {
    label: '立账条件ID',
    field: 'accountConditionId',
    component: 'Input',
    show:false
  },
  {
    label: '立账条件',
    field: 'accountConditionName',
    component: 'Input',
    slot: 'accountConditionSlot'
  },
  {
    label: '分类',
    field: 'supplierClass',
    component: 'Input',
  },
  {
    label: '发票核销顺序',
    field: 'invoiceWriteOffOrder',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"supplier_invoice_write_off_order",
        stringToNumber: true,
     },
  },
  {
    label: '行业',
    field: 'trade',
    component: 'Input',
  },
  {
    label: '核销明细',
    field: 'writeOffDetail',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"supplier_write_off_detail",
        stringToNumber: true,
     },
  },
  {
    label: '收货原则ID',
    field: 'receivingPrincipleId',
    component: 'Input',
    show:false,
  },
  {
    label: '收货原则',
    field: 'receivingPrincipleName',
    component: 'Input',
    slot: 'receivingPrincipleSlot'
  },
  {
    label: '单据核销顺序',
    field: 'billWriteOffOrder',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"supplier_billWrite_off_order",
        stringToNumber: true,
     },
  },
  {
    label: '办公地址',
    field: 'officeAddress',
    component: 'Input',
  },
  {
    label: '启用状态',
    field: 'enableStatus',
    defaultValue: 1,
     component: 'JSwitch',
     componentProps:{
         options:[1,0]
     },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}